home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / hm--html-menus / hm--html-mode.el.z / hm--html-mode.el
Encoding:
Text File  |  1998-05-21  |  10.9 KB  |  350 lines

  1. ;;; hm--html-mode --- Major mode for editing HTML documents for the WWW
  2.  
  3. ;; Copyright (C) 1996, 1997 Heiko Muenkel
  4.  
  5. ;; Author: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
  6. ;; Keywords: hypermedia languages help docs wp
  7.  
  8. ;; $Id: hm--html-mode.el,v 1.10 1997/07/20 06:36:20 muenkel Exp $
  9.  
  10. ;; This file is part of XEmacs.
  11.  
  12. ;; XEmacs is free software; you can redistribute it and/or modify it
  13. ;; under the terms of the GNU General Public License as published by
  14. ;; the Free Software Foundation; either version 2, or (at your
  15. ;; option) any later version.
  16.  
  17. ;; This program is distributed in the hope that it will be useful, but
  18. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20. ;; General Public License for more details.
  21.  
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with XEmacs; See the file COPYING. if not, write to the Free
  24. ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  25. ;; 02111-1307, USA
  26.  
  27. ;;; Synched up with: Not part of Emacs.
  28.  
  29. ;;; Commentary:
  30.  
  31. ;; Description:
  32.  
  33. ;;    This file defines the hm--html-mode, a mode for editing html
  34. ;;    files. It is the main file of the package hm--html-menus.
  35. ;;    Previous releases had used the file html-mode.el from Marc
  36. ;;    Andreessen. In that times the mode was called html-mode. I've
  37. ;;    changed the name of the mode to distinquish it from other
  38. ;;    html modes. But feel free to set a 
  39. ;;        (defalias 'hm--html-mode 'html-mode)
  40. ;;    to get back the old name of the mode.
  41.  
  42. ;;    In the earlier releases of the package the main file was
  43. ;;    hm--html-menu.el. This has been changed to hm--html-mode.el.
  44.  
  45.  
  46. ;; Installation: 
  47.  
  48. ;;    Put this file and all the other files of the package
  49. ;;    in one of your load path directories and the
  50. ;;    following lines in your .emacs:
  51.  
  52. ;;    (autoload 'hm--html-mode "hm--html-mode" "HTML major mode." t)
  53.  
  54. ;;    (or (assoc "\\.html$" auto-mode-alist)
  55. ;;         (setq auto-mode-alist (cons '("\\.html$" . hm--html-mode) 
  56. ;;                        auto-mode-alist)))
  57. ;;    If there is already another html-mode (like psgml in the XEmacs
  58. ;;    19.14, then you must put the following instead of the last form
  59. ;;    in your .emacs:
  60. ;;    (setq auto-mode-alist (cons '("\\.html$" . hm--html-mode) 
  61. ;;                        auto-mode-alist))
  62.  
  63. ;;    But you can also use the hm--html-minor-mode as an addition to
  64. ;;    the psgml html modes. For that you've to put the following line in
  65. ;;    your .emacs:
  66. ;;    (add-hook 'html-mode-hook 'hm--html-minor-mode)
  67.  
  68. ;;    Note: This works only in an XEmacs version greater than 19.14 and
  69. ;;    also not in the XEmacs 20.0.
  70.  
  71. ;;    Look at the file hm--html-configuration for further installation
  72. ;;      points.
  73.  
  74. ;;; Code:
  75.  
  76. (require 'font-lock)
  77. (require 'cl)
  78. (require 'adapt)
  79. (require 'hm--date)
  80. (require 'hm--html)
  81. ;(require 'hm--html-not-standard)
  82.  
  83. (eval-when-compile
  84.   (require 'hm--html-configuration))
  85.  
  86. (hm--html-load-config-files)
  87. (require 'hm--html-indentation)
  88.  
  89. (defvar hm--html-minor-mode nil
  90.   "Non-nil, if the `hm--html-minor-mode' is active.")
  91.  
  92. (require 'hm--html-menu)
  93.  
  94. (require 'hm--html-keys)
  95.  
  96. ;(defvar hm--html-minor-mode nil
  97. ;  "Non-nil, if the `hm--html-minor-mode' is active.")
  98. ;
  99. ;(require 'hm--html-menu)
  100. (require 'hm--html-drag-and-drop)
  101.  
  102.  
  103. ;;; The package version
  104. (defconst hm--html-menus-package-maintainer "muenkel@tnt.uni-hannover.de")
  105.  
  106. (defconst hm--html-menus-package-name "hm--html-menus")
  107.  
  108. (defconst hm--html-menus-package-version "5.8")
  109.   
  110.  
  111. ;;; Generate the help buffer faces
  112. (hm--html-generate-help-buffer-faces)
  113.  
  114. ;;; syntax table
  115.  
  116. (defvar hm--html-mode-syntax-table nil
  117.   "Syntax table used while in html mode.")
  118.  
  119. (if hm--html-mode-syntax-table
  120.     ()
  121.   (setq hm--html-mode-syntax-table (make-syntax-table))
  122. ;  (modify-syntax-entry ?\" ".   " hm--html-mode-syntax-table)
  123. ;  (modify-syntax-entry ?\\ ".   " hm--html-mode-syntax-table)
  124. ;  (modify-syntax-entry ?'  "w   " hm--html-mode-syntax-table)
  125.   (modify-syntax-entry ?\\ "." hm--html-mode-syntax-table)
  126.   (modify-syntax-entry ?'  "w" hm--html-mode-syntax-table)
  127.   (modify-syntax-entry ?<  "(>" hm--html-mode-syntax-table)
  128.   (modify-syntax-entry ?>  ")<" hm--html-mode-syntax-table)
  129.   (modify-syntax-entry ?\" "\"" hm--html-mode-syntax-table)
  130.   (modify-syntax-entry ?=  "."  hm--html-mode-syntax-table))
  131.  
  132.  
  133. ;;; abbreviation table
  134.  
  135. (defvar hm--html-mode-abbrev-table nil
  136.   "Abbrev table used while in html mode.")
  137.  
  138. (define-abbrev-table 'hm--html-mode-abbrev-table ())
  139.  
  140. ;;; the hm--html-mode
  141.  
  142. (defvar hm--html-mode-name-string "HTML"
  143.   "The hm--html-mode name string.")
  144.  
  145. ;;;###autoload
  146. (defun hm--html-mode ()
  147.   "Major mode for editing HTML hypertext documents.  
  148. Special commands:\\{hm--html-mode-map}
  149. Turning on hm--html-mode calls the value of the variable hm--html-mode-hook,
  150. if that value is non-nil."
  151.   (interactive)
  152.   (kill-all-local-variables)
  153.   (use-local-map hm--html-mode-map)
  154.   (setq mode-name hm--html-mode-name-string)
  155.   (setq major-mode 'hm--html-mode)
  156.   (setq local-abbrev-table hm--html-mode-abbrev-table)
  157.   (set-syntax-table hm--html-mode-syntax-table)
  158.   (make-local-variable 'comment-start)
  159.   (make-local-variable 'comment-end)
  160.   (setq comment-start "<!--" comment-end "-->")
  161.   (make-local-variable 'sentence-end)
  162.   (setq sentence-end "[<>.?!][]\"')}]*\\($\\| $\\|\t\\|  \\)[ \t\n]*")
  163.   (make-local-variable 'indent-line-function)
  164.   (setq indent-line-function 'hm--html-indent-line)
  165.   (setq idd-actions hm--html-idd-actions)
  166.   (hm--install-html-menu hm--html-mode-pulldown-menu-name)
  167.   (make-variable-buffer-local 'write-file-hooks)
  168.   (add-hook 'write-file-hooks 'hm--html-maybe-new-date-and-changed-comment)
  169.   (if (adapt-xemacsp)
  170.       (put major-mode 'font-lock-defaults '((hm--html-font-lock-keywords
  171.                          hm--html-font-lock-keywords-1
  172.                          hm--html-font-lock-keywords-2)
  173.                         t
  174.                         t
  175.                         nil
  176.                         nil))
  177.     (make-local-variable 'font-lock-defaults)
  178.     (setq font-lock-defaults '((hm--html-font-lock-keywords
  179.                 hm--html-font-lock-keywords-1
  180.                 hm--html-font-lock-keywords-2)
  181.                    t
  182.                    t
  183.                    nil
  184.                    nil)))
  185.   (run-hooks 'hm--html-mode-hook))
  186.  
  187. ;;;; Minor Modes
  188.  
  189. ;;; hm--html-region-mode 
  190.  
  191. (defvar hm--html-region-mode nil
  192.   "T, if the region is active in the `hm--html-mode'.")
  193.  
  194. (make-variable-buffer-local 'hm--html-region-mode)
  195.  
  196. (add-minor-mode 'hm--html-region-mode " Region" hm--html-region-mode-map)
  197.  
  198. (if (adapt-xemacsp)
  199.  
  200.     (defun hm--html-region-mode (&optional arg)
  201.       "Toggle 'hm--html-region-mode'.
  202. With ARG, turn hm--html-region-mode on iff ARG is positive.
  203.  
  204. If the `major-mode' isn't the `hm--html-mode' then the minor
  205. mode is switched off, regardless of the ARG and the state
  206. of `hm--html-region-mode'."
  207.       (interactive "P")
  208.       (setq zmacs-regions-stays t)
  209.       (setq hm--html-region-mode
  210.         (and (eq major-mode 'hm--html-mode)
  211.          (if (null arg) (not hm--html-region-mode)
  212.            (> (prefix-numeric-value arg) 0))))
  213.       )
  214.  
  215.     (defun hm--html-region-mode (&optional arg)
  216.       "Toggle 'hm--html-region-mode'.
  217. With ARG, turn hm--html-region-mode on iff ARG is positive.
  218.  
  219. If the `major-mode' isn't the `hm--html-mode' then the minor
  220. mode is switched off, regardless of the ARG and the state
  221. of `hm--html-region-mode'."
  222.       (interactive "P")
  223.       (setq hm--html-region-mode
  224.         (and (eq major-mode 'hm--html-mode)
  225.          (if (null arg) (not hm--html-region-mode)
  226.            (> (prefix-numeric-value arg) 0))))
  227.       (if hm--html-region-mode
  228.       (define-key hm--html-mode-map
  229.         hm--html-emacs19-popup-noregion-menu-button
  230.         nil)
  231.     (if hm--html-expert
  232.         (define-key hm--html-mode-map
  233.           hm--html-emacs19-popup-noregion-menu-button
  234.           hm--html-menu-noregion-expert-map)
  235.       (define-key hm--html-mode-map
  236.           hm--html-emacs19-popup-noregion-menu-button
  237.           hm--html-menu-noregion-novice-map)))
  238.       )
  239.  
  240.     )
  241.  
  242.  
  243. ;;; hm--html-minor-mode
  244. (make-variable-buffer-local 'hm--html-minor-mode)
  245.  
  246. (add-minor-mode 'hm--html-minor-mode " HM-HTML" hm--html-minor-mode-map)
  247.  
  248. ;;;###autoload
  249. (defun hm--html-minor-mode (&optional arg)
  250.   "Toggle hm--html-minor-mode.
  251. With arg, turn hm--html-minor-mode on iff arg is positive."
  252.   (interactive "P")
  253.   (setq hm--html-minor-mode
  254.     (if (null arg) (not hm--html-minor-mode)
  255.       (> (prefix-numeric-value arg) 0)))
  256.   (if hm--html-minor-mode
  257.       (progn
  258.     (hm--install-html-menu hm--html-minor-mode-pulldown-menu-name)
  259.     (when (adapt-emacs19p)
  260.       (hm--html-add-major-menu-to-minor-menus)))
  261.     (when (and (featurep 'menubar)
  262.            current-menubar (assoc hm--html-minor-mode-pulldown-menu-name
  263.                       current-menubar))
  264.       (delete-menu-item (list hm--html-minor-mode-pulldown-menu-name)))
  265.     (when (adapt-emacs19p)
  266.       (hm--html-remove-major-menu-from-minor-menus)))
  267.   )
  268.   
  269.  
  270. ;;; hm--html-minor-region-mode
  271.  
  272. (defvar hm--html-minor-region-mode nil
  273.   "Non-nil, if the `hm--html-minor-region-mode' is active.")
  274.  
  275. (make-variable-buffer-local 'hm--html-minor-region-mode)
  276.  
  277. (add-minor-mode 'hm--html-minor-region-mode 
  278.         " Region" 
  279.         hm--html-minor-region-mode-map)
  280.  
  281.  
  282. (if (adapt-xemacsp)
  283.  
  284.     (defun hm--html-minor-region-mode (&optional arg)
  285.       "Toggle `hm--html-minor-region-mode'.
  286. With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
  287.  
  288. But however, if the `hm--html-minor-mode' isn't active, then it
  289. turns `hm--html-minor-region-mode' off."
  290.       (interactive "P")
  291.       (setq zmacs-regions-stays t)
  292.       (setq hm--html-minor-region-mode
  293.         (and hm--html-minor-mode
  294.          (if (null arg) (not hm--html-minor-region-mode)
  295.            (> (prefix-numeric-value arg) 0))))
  296.       )
  297.  
  298.     (defun hm--html-minor-region-mode (&optional arg)
  299.       "Toggle `hm--html-minor-region-mode'.
  300. With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
  301.  
  302. But however, if the `hm--html-minor-mode' isn't active, then it
  303. turns `hm--html-minor-region-mode' off."
  304.       (interactive "P")
  305.       (setq hm--html-minor-region-mode
  306.         (and hm--html-minor-mode
  307.          (if (null arg) (not hm--html-minor-region-mode)
  308.            (> (prefix-numeric-value arg) 0))))
  309.       (if hm--html-minor-region-mode
  310.       (define-key hm--html-minor-mode-map
  311.         hm--html-emacs19-popup-noregion-menu-button
  312.         nil)
  313.     (if hm--html-expert
  314.         (define-key hm--html-minor-mode-map
  315.           hm--html-emacs19-popup-noregion-menu-button
  316.           hm--html-menu-noregion-expert-map)
  317.       (define-key hm--html-minor-mode-map
  318.           hm--html-emacs19-popup-noregion-menu-button
  319.           hm--html-menu-noregion-novice-map)))
  320.       )
  321.     )
  322.  
  323.   
  324.  
  325. ;;; Hook function for toggling the region minor modes
  326. (defun hm--html-switch-region-modes-on ()
  327.   "Switches the region minor modes of the hm--html-menus package on.
  328. This function should be only be used for the `zmacs-activate-region-hook'
  329. or for the `activate-mark-hook'."
  330.   (hm--html-region-mode 1)
  331.   (hm--html-minor-region-mode 1))
  332.  
  333. (defun hm--html-switch-region-modes-off ()
  334.   "Switches the region minor modes of the hm--html-menus package on.
  335. This function should be only be used for the `zmacs-deactivate-region-hook'
  336. or for the `deactivate-mark-hook'."
  337.   (hm--html-region-mode -1)
  338.   (hm--html-minor-region-mode -1))
  339.     
  340.  
  341. ;;; Run the load hook
  342. (run-hooks 'hm--html-load-hook)
  343.  
  344.  
  345. ;;; Announce the feature hm--html-configuration
  346. (provide 'hm--html-mode)
  347.  
  348.  
  349. ;;; hm--html-mode.el ends here
  350.